fn main() {
    let s1 = String::from("hello");

    let len = calculate_length(&s1);

    println!("The length of '{}' is {}.", s1, len);
    mut_ref();
}

fn calculate_length(s: &String) -> usize {
    // s.push_str("hello");
    // ^ `s` is a `&` reference, so the data it refers to cannot be borrowed as mutable
    s.len()
}

fn mut_ref() {
    let mut s1 = String::from("hello");

    calculate_length_mut(&mut s1);
}

fn calculate_length_mut(s: &mut String) -> usize {
    s.push_str("hello");
    s.len()
}
